Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

Application-Defined Function

The standard image-compression dialog component supplied by Apple allows you to extend the interface of the standard dialog box by defining a hook function. This section describes how that hook function operates.

MyHook

This function is called by the standard dialog component whenever the user selects an item in the standard image-compression dialog box. You define the function in your application and assign it to a dialog box with the hookProc field of the scExtendedProcsType request, which is discussed on The Extended Functions Request Type .

This is how you would define a hook function called MyHook :

pascal short MyHook (DialogPtr theDialog, short itemHit,
                                         void *params, long refcon);
theDialog
Contains a pointer to the dialog structure that identifies the current dialog box.
itemHit
Identifies the item clicked by the user.
params
Contains a pointer to a field that contains the identifier for your connection to the standard dialog component. You can use this identifier to call the dialog component's SCGetInfo or SCSetInfo functions.
refcon
Contains the reference constant value you supplied to the SCGetCompressionExtended function.

DESCRIPTION

Your hook function returns a short integer that identifies the item selected by the user. In general, your hook function should return the same item number it receives in the itemHit parameter. By returning a specific value, you can affect how the component handles the user selection. The following values are defined:

scOKItem
Indicates that the user clicked the OK button.
scCancelItem
Indicates that the user clicked the Cancel button.
scCustomItem
Indicates that the user clicked the custom button.

If you set the returned value to 0, you cancel the user selection; the dialog box remains on the screen awaiting further action by the user.

The hook function allows your application to tailor or extend the operation of the standard image-compression dialog box. By attaching your hook function to the dialog box, you intercept all user selections. For example, your hook function could perform additional parameter checking whenever the user clicks the OK button. In this case, whenever you detect an incorrect parameter value, you could display a message to the user and then set the returned value to 0, thereby canceling the user's selection. The user would then either cancel the dialog box or try again.

As another example, you could support additional parameters by implementing the dialog box's custom button. You could use your hook function to display a secondary dialog box whenever the user clicks the custom button. For an example of defining and using a custom button, see "Extending the Basic Dialog Box" beginning on Extending the Basic Dialog Box .


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next